package com.guigu.controller.lq.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.guigu.controller.lq.mapper.LqModelMapper;
import com.guigu.controller.lq.pojo.LqModel;
import com.guigu.controller.lq.pojo.PageVO;
import com.guigu.controller.lq.service.LqModelService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class LqModelServiceimpl implements LqModelService {
    @Autowired
    LqModelMapper lqModelMapper;
    public PageVO<LqModel> find(Integer page, Integer num, String modeltitle) {
        PageHelper.startPage(page,num);
        LqModel lqModel = new LqModel();
        lqModel.setModeltitle(modeltitle);
        List<LqModel> findmod = lqModelMapper.findmod(lqModel);
        PageInfo<LqModel> pageInfo = new PageInfo<LqModel>(findmod);
        long total = pageInfo.getTotal();
        PageVO<LqModel> PageVO = new PageVO<LqModel>();
        PageVO.setTotal(total);
        PageVO.setRows(findmod);
        return PageVO;
    }

    public int tjmb(LqModel lqMotion) {
        return lqModelMapper.insert(lqMotion);
    }

    public LqModel selmb(Integer id) {
        return lqModelMapper.selmb(id);
    }

    public int upzt(LqModel lqModel) {
        return lqModelMapper.upzt(lqModel);
    }

    public int delmb(Integer id) {
        return lqModelMapper.deleteByPrimaryKey(id);
    }

    public int upmb(LqModel lqModel) {
        return lqModelMapper.updateByPrimaryKey(lqModel);
    }

    public List<LqModel> findmbgy(LqModel lqModel) {
        return lqModelMapper.findmbgy(lqModel);
    }
}
